import React from 'react'
import { ChessType } from '../types/enums'
import { ChessC } from './ChessC'
import './BoardC.css'

interface BoardCprops {
	chesses: ChessType[]
	handleClick?: (index: number) => void
	isGameOver?: boolean
}

export const BoardC: React.FC<BoardCprops> = (props = { isGameOver: false, chesses: [] }) => {
	const isGameOver = props.isGameOver!
	const list = props.chesses.map((type, index) => (
		<ChessC
			key={index}
			type={type}
			handleClick={() => {
				props.handleClick && !isGameOver && props.handleClick(index)
			}}
		/>
	))
	return <div className="board">{list}</div>
}
